
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="stripes" uri="http://stripes.sourceforge.net/stripes.tld" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ include file="/support/taglibs.jsp" %>


<stripes:layout-render name="/support/layout/standard.jsp" title="Edit/Add Collaboration" page="collaborations">
<stripes:layout-component name="contents">
<stripes:errors action="/CollaborationForm.action"/>
<jsp:useBean id="isernManager" scope="page"
           class="edu.hawaii.myisern.model.IsernManager"/>
           
<stripes:form action="/CollaborationForm.action" id="MyForm">
    <input type="hidden" name="existedOrganization" value="">

 <table class="leftRightForm">
                <tr>
                    <th>ID:</th>
                    <td>${empty actionBean.id ? "n/a" : actionBean.id}
                        <stripes:hidden name="id"/>
                    </td>
                 </tr>
                 <tr>
                    <th>Name:</th>
                    <td><stripes:text name="collaboration.name"  />
                    </td>                 
                 </tr>
                 <tr>
                    <th>Description:</th>
                    <td><stripes:textarea  name="collaboration.description"  />
                    </td>                 
                 </tr>
                 <tr>
                    <th>Year:</th>
                    <td><stripes:select name="collaborationYears" multiple="true" style="width: 100px; height:5em;">
                            <stripes:options-collection collection="${isernManager.yearOptions}" />
                        </stripes:select>            
                    </td>                 
                 </tr>
                 <tr>
                    <th>Collaborating<br />Organizations:</th>    
                    <td><table>
                    <c:forEach items="${actionBean.collaboratingOrganizations}" var="organization" varStatus="loop">
          			 <tr>
                     <td><input type="hidden" name="collaboratingOrganizations" value="${organization}"/>${organization}</td>
                     <td>
                     	
            			<div class="buttons">
                        	<stripes:submit name="removeOrganization" value=" - " onclick="MyForm.existedOrganization.value='${organization}';"/>
                        </div>
                     </td>
                     </tr>
        			</c:forEach>   
                    <tr>
                    <td>
                        <stripes:select name="currentOrganization">
                            <stripes:options-collection collection="${isernManager.organizations}"
                            label="name" value="name" />
                        </stripes:select>
                    </td>
                    <td>
            			<div class="buttons">
                        	<stripes:submit name="addOrganization" value="Add"/>
                        </div>
                    </td></tr>   
                    </table></td>                       
                 <tr>
                 </tr>                 
                    <th>Outcome Types:</th>     
                    <td><stripes:textarea name="outcomeTypes" 
                              value="${outcomeTypes}"
                              class="text" 
                              rows="5" 
                              cols="40" />      
                    </td>                      
                 </tr>
                 </tr>                 
                    <th>Collaboartion Types:</th>     
                    <td><stripes:textarea name="collaborationTypes" 
                              value="${collaborationTypes}"
                              class="text" 
                              rows="5" 
                              cols="40" />
                    </td>  
                 </tr> 
            </table>
            
            <div class="buttons">
                <stripes:submit name="save" value="Save"/>
                <stripes:submit name="remove" value="Remove" onclick="return confirm('Are you sure you want to remove Collaboration ${actionBean.collaboration.name}?')"/>
            </div>
           </stripes:form>
    </stripes:layout-component>
</stripes:layout-render>
